//
//  ProfileHost.swift
//  test-ios
//
//  Created by wyz5204 on 2023/3/28.
//

import Foundation
import SwiftUI

struct Food {
    let name :String
    let image:String
    let calorie:Double
    let carb : Double
    let fat :Double
    let protein : Double
    
    static let foods = [
        Food(name: "汉堡", image: "🥧", calorie: 294, carb: 14, fat: 24, protein: 17),
        Food(name: "沙拉", image: "🥖", calorie: 294, carb: 14, fat: 24, protein: 17),
        Food(name: "披萨", image: "🥟", calorie: 294, carb: 14, fat: 24, protein: 17),
        Food(name: "意大利面", image: "🍝", calorie: 294, carb: 14, fat: 24, protein: 17),
        Food(name: "鸡腿便当", image: "🍗", calorie: 294, carb: 14, fat: 24, protein: 17),
        Food(name: "刀削面", image: "🍰", calorie: 294, carb: 14, fat: 24, protein: 17),
        Food(name: "火锅", image: "🥙", calorie: 294, carb: 14, fat: 24, protein: 17),
        Food(name: "牛肉面", image: "🍜", calorie: 294, carb: 14, fat: 24, protein: 17),
        Food(name: "关东煮", image: "🥘", calorie: 294, carb: 14, fat: 24, protein: 17),
    ]
}

struct ProfileHost : View{
    
    @State private var draftProfile = Profile.default
    
    
    var body: some View{
        Text("Profile for: \(draftProfile.username)")
    }
    
}

struct ColumeView : View {
    let foods = ["面条1","面条2","面条3","面条4","面条5","面条6","面条7","面条8","面条9","面条10"]
    
    @State var current : String?
    
    var body: some View{
        VStack(spacing : 10){
            
            Image("lif1").resizable().aspectRatio(contentMode: .fit)
            if current != .none {
                Text(current!).font(.largeTitle).bold()
            }
            
            Button("告诉我吃啥？"){
                print("吃屁啊")
                current = foods.shuffled().filter({ curr -> Bool in
                    return curr != current
                }).first
            }.font(.title)
            
            Button {
                current = .none
            } label: {
                Text("重置").frame(width: 100)
            }.background(Color.red)
        }.padding().animation(.easeInOut, value:current ).frame(maxHeight:.infinity)
        
    }
}

struct ProfileHost_Previews: PreviewProvider {
    static var previews: some View {
        ColumeView()
    }
}
